package com.ylyq.ylxx.controller;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ylyq.ylxx.entity.YlyqCreativeTitleV2;
import com.ylyq.ylxx.entity.YlyqCreativeVideoMaterial;
import com.ylyq.ylxx.entity.YlyqPlanStopStart;
import com.ylyq.ylxx.model.ResponseData;
import com.ylyq.ylxx.model.request.SavePlanToSmartRequest;
import com.ylyq.ylxx.service.IYlyqCreativeTitleV2Service;
import com.ylyq.ylxx.service.IYlyqCreativeVideoMaterialService;
import com.ylyq.ylxx.service.IYlyqPlanStopStartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * <p>
 * 保存需要智能启停的计划 前端控制器
 * </p>
 *
 * @author xiaweichao
 * @since 2020-08-04
 */
@RestController
@RequestMapping("/planStopOrStart")
@Api(description = "计划智能启停的相关接口")
public class YlyqPlanStopStartController {
    @Autowired
    private IYlyqPlanStopStartService iYlyqPlanStopStartService;

    @PostMapping("/savePlanToSmart")
    @ApiOperation(value = "保存计划至智能启停")
    public ResponseData savePlanToSmart(@RequestBody List<SavePlanToSmartRequest> savePlanToSmartRequestList) {

        for (SavePlanToSmartRequest savePlanToSmartRequest:savePlanToSmartRequestList) {
            YlyqPlanStopStart ylyqPlanStopStart=new YlyqPlanStopStart();
            BeanUtils.copyProperties(savePlanToSmartRequest,ylyqPlanStopStart);
            iYlyqPlanStopStartService.save(ylyqPlanStopStart);
        }
        return new ResponseData(ResponseData.Result.SUCCESS);
    }
}
